package cn.edu;

import cn.edu.dao.BookDao;
import cn.edu.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;

/**
 * @author Davey chan
 */
public class App {
    public static void main(String[] args) {
//        获取IOC容器:目的是为了解耦
//        从加载类路径下的配置文件来获取容器，还有一个是从文件系统下加载配置文件
        ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
//        获取bean 也有不同的方法(强转，类.class,名称+指定类型)
//       BookDao bookDao = (BookDao) ctx.getBean("bookDao");
//        BookDao bookDao =  ctx.getBean("bookDao",BookDao.class);
        BookDao bookDao =  ctx.getBean(BookDao.class);
        bookDao.save();
      /*   BookService bookService =(BookService) ctx.getBean("bookService");
        bookService.save();*/
//        DataSource dataSource = (DataSource)ctx.getBean("dataSource");
//        System.out.println(dataSource);
    }
}
